<?php $this->renderPartial('_tabs'); ?>

<div class="grid_16 content_header clearfix">
	<h1 class="float-left">Word Filters</h1>
	<div class="content_header_controls">
		<a id="addFilter" class="link-button with-icon" href="<?php echo $this->createUrl('adsControl/createFilter'); ?>">
			<img src="/images/icons/fugue/document--plus.png" />
			Create Filter
		</a>
	</div>
</div>

<div class="grid_16 relative">
    <div class="manage-accounting form">
		<?php
		$this->widget('PsGridView', array(
			'id' => 'manage-filters-grid',
			'dataProvider' => $dataProvider,
			'filter' => $adfilter,
			'template' => '{pager}{pagesize}{items}',
			'pagerCssClass' => 'pager float-right',
			'pagesizeCssClass' => 'pager-pagesize',
			'htmlOptions' => array(
				'class' => 'grid-view no-shadow'
			),
			'rowCssClassExpression' => '($row % 2 == 0 ? "even" : "odd")',
			'columns' => array(
				'taxType' => array(
					'header' => 'Phrase/Word to filter',
					'name' => 'phrase',
					'type' => 'raw',
					'value' => '$data->phrase',
					'htmlOptions' => array(
						'class' => 'name',
					)
				),
				'score' => array(
					'header' => 'Score',
					'name' => 'score',
					'type' => 'raw',
					'value' => '$data->score',
					'htmlOptions' => array(
						'class' => 'team',
						'width' => 150
					)
				),
				'create_time' => array(
					'header' => 'Created On',
					'name' => 'create_time',
					'type' => 'raw',
					'value' => 'date("d M Y", strtotime($data->create_time))',
					'htmlOptions' => array(
						'class' => 'team',
						'width' => 150
					)
				),
				'exist' => array(
					'header' => 'Appears in Ads?',
					'name' => 'exist',
					'type' => 'raw',
					'filter' => false,
					'value' => '(count(Advertisement::checkCurrentAdvertisements($data->phrase)) == 0 ? "No" : "Yes")',
					'htmlOptions' => array(
						'class' => 'team',
						'width' => 120
					)
				),
				array(
					'header' => 'Actions',
					'class' => 'common.widgets.grid.PsActionColumn', // protected/components/PsActionColumn.php
					'htmlOptions' => array(
						'class' => 'action-column',
						'width' => '120'
					),
					'options' => array(
						'width' => '170'
					),
					'actions' => array(
						'edit' => array(
							'label' => 'Edit Filter',
							'icon' => '/images/icons/farmfresh/16x16/layout_edit.png',
							'class' => 'adfilter',
							'url' => array('adsControl/updateFilter', 'id' => '$data->id'),
						),
						'delete' => array(
							'label' => 'Delete Filter',
							'icon' => '/images/icons/fugue/cross-circle.png',
							'class' => 'adfilter',
							'onClick' => 'js:function(action) {return window.confirm("Remove Filter?");}',
							'url' => array('adsControl/deleteFilter', 'id' => '$data->id'),
						),
						'review' => array(
							'label' => 'View ads having this filter',
							'icon' => '/images/icons/fugue/magnifier.png',
							'class' => 'adfilter',
							'url' => array('adsControl/adsToReview', 'id' => '$data->id'),
							'disabled' => '(count(Advertisement::checkCurrentAdvertisements($data->phrase)) == 0 ? true : false)'
						)
					)
				)
			)
		));
		?>
    </div>
</div>

